import { GCellRenderer } from "../../../../../com/mui/controls/GCellRenderer";
import { ItemData } from "../../../resource/info/ItemData";
import { Language } from "../../../../../extend/language/Language";
import { ObjCreate } from "../../common/ObjCreate";
import { ImagesConst } from "../../../resource/ImagesConst";
import { BaseItem } from "../../common/BaseItem";
import { FilterConst } from "../../../../component/gconst/FilterConst";
import { QuickBuyWindow } from "../../common/QuickBuyWindow";
import { ECategory } from "../../../../../Message/Public/ECategory";
import { EProp } from "../../../../../Message/Public/EProp";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { GButton } from "../../../../../com/mui/controls/GButton";
//class PetSkillYiRenderer
    
    export  class PetSkillYiRenderer extends GCellRenderer
    {
        constructor()
        {
            super();
            this.init();
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            super.data = arg1;
            this._itemData = arg1 as ItemData;
            this._baseItem.itemData = this._itemData;
            if (this._itemData) 
            {
                this._operBtn.label = Language.getString(54162);
                this._isBuy = false;
            }
            else 
            {
                this._operBtn.label = Language.getString(54163);
                this._isBuy = true;
            }
            this._operBtn.drawNow();
            return;
        }

        /* internal  */init(): void
        {
            ObjCreate.createBg(0, 0, 38, 38, this, ImagesConst.PackItemBg);
            this._baseItem = new BaseItem();
            this._baseItem.isShowLock = true;
            this._baseItem.isDragAble = false;
            this._baseItem.width = 32;
            this._baseItem.height = 32;
            this._baseItem.move(3, 3);
            this.addChild(this._baseItem);
            this._operBtn = ObjCreate.createGButton(Language.getString(54163), 0, 42, 40, 22, this);
            this._operBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onOperBtnClickHandler);
            return;
        }

        public /* override */ set selected(arg1: Boolean)
        {
            super.selected = arg1;
            if (arg1 && this._itemData) 
            {
                this._baseItem.filters = [FilterConst.itemChooseFilter];
            }
            else 
            {
                this._baseItem.filters = [];
            }
            return;
        }

        /* internal  */onOperBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (this._isBuy) 
            {
                QuickBuyWindow.instance.updateWindow(ECategory._ECategoryProp, EProp._EPropPetSkillRand);
                QuickBuyWindow.instance.updateDefaultAmount(1);
                QuickBuyWindow.instance.show();
            }
            else if (this._itemData) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.PetSkillOpenRefreshWindow, this._itemData));
            }
            return;
        }

        /* internal */ /* var */_baseItem: BaseItem;

        /* internal */ /* var */_itemData: ItemData;

        /* internal */ /* var */_operBtn: GButton;

        /* internal */ /* var */_isBuy: Boolean;
    }
